import {
  fetch
} from './ajax';


// 首页获取token和id

export function getToken_Axios(code) {
  return fetch({
    url: 'http://122.152.216.183:8092/home/login/accesstoken',
    method: 'get',
    params: {
      code: code
    },
  })
}

//公告模块-----------------------------------------------------

//获取公告
export function getNotice_Axios() {
  return fetch({
    url: 'http://122.152.216.183:8092/announcement',
    method: 'get',
  })
}

//签到模块-----------------------------------------------------

//获取签到信息
export function getDaily_Axios(userId) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/sign/' + userId,
    method: 'get',
  })
}

//签到
export function putDaily_Axios(userId) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/sign/' + userId,
    method: 'put',
  })
}


//文章管理模块--------------------------------------------------

//获取文章列表
export function getAriticleList_Axios(size) {
  return fetch({
    url: 'http://122.152.216.183:8092/articles',
    method: 'get',
    params: {
      size: size,
    }
  })
}

//获取文章banner图
export function getAriticleBanner_Axios() {
  return fetch({
    url: 'http://122.152.216.183:8092/articles/banner',
    method: 'get',
  })
}

//获取文章详情
export function getArticle_Axios(a_id, userId) {
  return fetch({
    url: 'http://122.152.216.183:8092/articles/' + a_id,
    method: 'get',
    params: {
      sid: userId,
    }
  })
}

//文章收藏接口
export function dislikeArticle_Axios(a_id, userId) {
  return fetch({
    url: "http://122.152.216.183:8092/articles/" + a_id + "/dislike",
    method: 'put',
    params: {
      sid: userId,
    }
  })
}
//取消文章收藏接口
export function likeArticle_Axios(a_id, userId) {
  return fetch({
    url: "http://122.152.216.183:8092/articles/" + a_id + "/like",
    method: 'put',
    params: {
      sid: userId,
    }
  })
}

//视频管理模块--------------------------------------------------

//获取视频列表
export function getVideoList_Axios(size, subject, gradeNum) {
  return fetch({
    url: 'http://122.152.216.183:8092/videos',
    method: 'get',
    params: {
      size: size,
      subject: subject,
      grade: gradeNum
    }
  })
}

//获取视频banner图
export function getVideoBanner_Axios() {
  return fetch({
    url: 'http://122.152.216.183:8092/videos/banner',
    method: 'get',
  })
}

//获取视频详情
export function getVideo_Axios(v_id, userId) {
  return fetch({
    url: 'http://122.152.216.183:8092/videos/' + v_id,
    method: 'get',
    params: {
      sid: userId,
    }
  })
}

//观看视频看过加1
export function watchVideo_Axios(v_id) {
  return fetch({
    url: "http://122.152.216.183:8092/videos/" + v_id,
    method: 'put',
  })
}

//取消视频收藏接口
export function dislikeVideo_Axios(v_id, userId) {
  return fetch({
    url: "http://122.152.216.183:8092/videos/" + v_id + "/dislike",
    method: 'put',
    params: {
      sid: userId,
    }
  })
}
//视频收藏接口
export function likeVideo_Axios(v_id, userId, subject) {
  return fetch({
    url: "http://122.152.216.183:8092/videos/" + v_id + "/like",
    method: 'put',
    params: {
      sid: userId,
      subject: subject,
    }
  })
}


//科目管理模块--------------------------------------------------

//获取科目
export function getSubject_Axios() {
  return fetch({
    url: 'http://122.152.216.183:8092/subjects/subjects',
    method: 'get',
  })
}

//学生证---------------------------------------------------------

// IDcard获取学生信息
export function getUser_Axios(userId) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/' + userId,
    method: 'get',
  })
}

// 基本资料

// 微信获取签名
export function getOAuth_Axios(wxUrl) {
  return fetch({
    url: 'http://122.152.216.183:8092/home/login/signature/',
    method: 'get',
    params: {
      url: wxUrl
    }
  })
}

// 获取基本信息详情
export function getUserInfo_Axios(userId) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/' + userId + "/info",
    method: 'get',
  })
}

// 更改年级
export function putGrade_Axios(userId, data) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/' + userId + "/grade",
    data: JSON.stringify(data),
    method: 'put',
  })
}
// 更改性别
export function putGender_Axios(userId, data) {
  return fetch({
    url: "http://122.152.216.183:8092/students/" + userId + "/gender",
    data: JSON.stringify(data),
    method: 'put',
  })
}


// 我的收藏获取文章列表
export function getMyArticle_Axios(userId, size) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/' + userId + "/articles",
    method: 'get',
    params: {
      size: size
    }
  })
}


// 删除文章
export function deleteArticle_Axios(userId, data) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/' + userId + "/articles",
    method: 'delete',
    data: JSON.stringify(data)
  })
}


// 获取收藏视频列表
export function getMyVideo_Axios(userId, size) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/' + userId + "/videos",
    method: 'get',
    params: {
      size: size
    }
  })
}

// 删除视频
export function deleteVideo_Axios(userId, data) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/' + userId + "/videos",
    method: 'delete',
    data: JSON.stringify(data)
  })
}

//收藏科目搜索 
export function checkSubject_Axios(userId, item) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/' + userId + "/videos",
    method: 'get',
    params: {
      subject: item
    },
    data: {
      emulateJSON: true
    }
  })
}

// 获取历史记录
export function getHistory_Axios(userId) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/' + userId + "/history",
    method: 'get',
  })
}


// 清空历史记录
export function deleteHistory_Axios(userId) {
  return fetch({
    url: 'http://122.152.216.183:8092/students/' + userId + "/history",
    method: 'delete',
  })
}

//获取绑定手机信息
export function getPhoneBind_Axios(userId) {
  return fetch({
    url: "http://122.152.216.183:8092/students/" + userId + "/phoneBind",
    method: 'get',
  })
}

//获取绑定邮箱信息
export function getEmailBind_Axios(userId) {
  return fetch({
    url: "http://122.152.216.183:8092/students/" + userId + "/emailBind",
    method: 'get',
  })
}

//获取手机验证码
export function getPhoneCode_Axios(userId, phone) {
  return fetch({
    url: "http://122.152.216.183:8092/students/" + userId + "/phone",
    method: 'post',
    headers: {
      'Content-type': 'application/x-www-form-urlencoded'
    },
    data: {
      phone: phone,
    },

  })
}

//获取邮箱验证码
export function getEmailCode_Axios(userId, email) {
  return fetch({
    url: "http://122.152.216.183:8092/students/" + userId + "/email",
    method: 'post',
    data: {
      email: email
    }
  })
}


//绑定手机
export function bindPhone_Axios(userId) {
  return fetch({
    url: "http://122.152.216.183:8092/students/" + userId + "/verifyphone",
    method: 'post',
  })
}

//绑定手机
export function bindEmail_Axios(userId) {
  return fetch({
    url: "http://122.152.216.183:8092/students/" + userId + "/verifyemail",
    method: 'post',
  })
}
